var edit = false;
// เพิ่มแถว กรณีกดปุ่ม เปลี่ยนรหัสผ่าน
function info_editPass()
{
	var table = document.getElementById("box-table-a");
	var row, cell;
	if(table.rows.length < 6)
	{
		row = table.insertRow(table.rows.length);
		cell = row.insertCell(0);
		cell.className = "col1";
		cell.innerHTML = "รหัสผ่านเดิม : ";	
		cell = row.insertCell(1);
		cell.innerHTML = "<input type=\"password\" id=\"info_txtPassword\" name =\"info_txtPassword\" style=\"width: 200px;\"></input>";

		
		row = table.insertRow(table.rows.length);	
		cell = row.insertCell(0);
		cell.className = "col1";
		cell.innerHTML = "รหัสผ่านใหม่ : ";	
		cell = row.insertCell(1);
		cell.innerHTML = "<input type=\"password\" id=\"info_txtNewPassword\" name =\"info_txtNewPassword\" style=\"width: 200px;\"></input>";
		
		row = table.insertRow(table.rows.length);	
		cell = row.insertCell(0);
		cell.className = "col1";
		cell.innerHTML = "พิมพ์รหัสผ่านอีกครั้ง   : ";	
		cell = row.insertCell(1);
		cell.innerHTML = "<input type=\"password\" id=\"info_txtPasswordChk\" name =\"info_txtPasswordChk\" style=\"width: 200px;\"></input>";
		
		edit = true;
		
		document.getElementById("info_achangePass").innerHTML = "ปิด";
	}
	else
	{
		for(var i = table.rows.length; i > 5; i--)
		{
			table.deleteRow(i-1);
			document.getElementById("info_achangePass").innerHTML = "<br> เปลี่ยนรหัสผ่านใหม่";
		}
	}
	
}

//อัพเดทข้อมูล
function info_update(pass)
{
	document.getElementById("webmaster_prename").value = document.getElementById("info_txtPrename").value;
	document.getElementById("webmaster_firstname").value = document.getElementById("info_txtFirstname").value;
	document.getElementById("webmaster_lastname").value =  document.getElementById("info_txtLastname").value;
	document.getElementById("webmaster_username").value = document.getElementById("info_txtUsername").value;
	if(edit)
	{
		if(document.getElementById("info_txtNewPassword").value != document.getElementById("info_txtPasswordChk").value)
		{
			alert("รหัสใหม่ไม่ตรงกันกรุณาพิมพ์ใหม่อีกครั้ง");
			return;
		}else
		{
			document.getElementById("webmaster_oldpassword").value = pass;
			document.getElementById("webmaster_password").value = document.getElementById("info_txtPassword").value;
			document.getElementById("webmaster_newpassword").value = document.getElementById("info_txtNewPassword").value;
			document.getElementById("webmaster_chkpassword").value = document.getElementById("info_txtPasswordChk").value;
		}					
	}
	document.forms["formSubmit"].submit();
	
}